package com.example.playbox

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity

class BackActivity : AppCompatActivity(), View.OnClickListener {
    // 定义组件
    private lateinit var btBackFalse: Button
    private lateinit var btBackTrue: Button

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_back) // 为该Activity的运行分配内存

        btBackFalse = findViewById(R.id.bt_backfalse)
        btBackFalse.setOnClickListener(this) // 监听

        btBackTrue = findViewById(R.id.bt_backtrue)
        btBackTrue.setOnClickListener(this) // 监听
    }

    override fun onClick(v: View) {
        when (v.id) { // 通过switch方法跳转到相应界面
            R.id.bt_backfalse -> {
                val intentInsert = Intent()
                val intent = intentInsert.setClass(this@BackActivity, PersonalCenterActivity::class.java)
                startActivity(intentInsert)
            }
            R.id.bt_backtrue -> {
                val intentQuery = Intent()
                intentQuery.setClass(this@BackActivity, LoginActivity::class.java)
                startActivity(intentQuery)
            }
        }
    }
}